ContractCloseShow = Ext.extend(Ext.Window,
{
	formPanel : null,
	constructor : function(a) {
		Ext.applyIf(this, a);
		this.initgridPlanPanel();
		this.initUIComponents();						
		ContractCloseShow.superclass.constructor.call(this, {
			layout : "fit",
		items : this.formPanel,
		modal : true,
		id : "ContractCloseShowWin",
		title : "合同审核",
		iconCls : "menu-productQuality",
		width : 800,
		height : 495,
		buttonAlign : "center",
		buttons : this.buttons
	});
},
initUIComponents : function() {
	this.radioGroup = new Ext.form.RadioGroup({
		fieldLabel : "关闭状态",
		allowBlank : false,
		anchor : "100%",
		id : "contract.contractCode.codeNo",
		name : "contract.contractCode.codeNo",
		items : [{
			name : "contract.contractCode.codeNo",
			boxLabel : "正常",
			inputValue : "001"
		},{
			name : "contract.contractCode.codeNo",
			boxLabel : "异常",
			inputValue : "002"
		}]
	});						
	this.formPanel = new Ext.FormPanel(
			{
				url : __ctxPath	+ "/contract/verifyContract.do",
				layout : "form",
				id : "ContractCloseShow",
				border : false,
				bodyStyle : "padding:5px;",
				defaults : {
					anchor : "98%,98%"
				},
				autoScroll:true,
				formId : "ContractCloseShowId", 
				items : [
									{
										id : "contractId",
										name : "contractId",
										xtype : "hidden",
										value : this.contractId == null ? "": this.contractId
									},
									{//第二行 
										layout : "column",
										items : [
												{
													columnWidth : .5,//第一列 
													layout : "form",
													border : false,
													bodyStyle : "padding:5px;",
													items : [ {
														xtype : "displayfield",
														fieldLabel : '合同名称'
																+ '<font color=red>*</font>',
														name : 'contract.contractName',
														id : 'contract.contractName',
														width : 150,
														allowBlank : false,
														blankText : "合同名称为空"
													} ]
												},{
													columnWidth : .5,//第一列 
													layout : "form",
													border : false,
													bodyStyle : "padding:5px;",
													items : [{
														xtype : "displayfield",
														fieldLabel : '合同编号'
																+ '<font color=red>*</font>',
														name : 'contract.contractNo',
														id : 'contract.contractNo',
														width : 150,
														allowBlank : false,
														blankText : "合同编号为空"
													} ]
												}
											]
									},
						{
							xtype : "fieldset",
							id : "ProductionPlanFieldset",
							columnWidth : 1,
							title : "生产计划信息",
							collapsed : false,
							collapsible : true,
							autoHeight : true,
							defaults : {
								anchor : "100%,100%"
							},
							items : [this.gridPlanPanel]
						},{
							xtype : "fieldset",
							id : "conQualityFieldset",
							columnWidth : 1,
							title : "合同审核信息",
							collapsed : false,
							collapsible : true,
							autoHeight : true,
							defaults : {
								anchor : "100%,100%"
							},
							items : [{
									    layout:"column", 
									    items:[{ 
									        columnWidth:1.,//第一列 
									        layout:"form", 
									        border : false,
									        bodyStyle : "padding:5px;",
									        items:this.radioGroup
									}]},
									{
									layout:"column", 
									items:[{ 
									    columnWidth:1,//第一列 
									    layout:"form", 
									    border : false,
									    bodyStyle : "padding:5px;",
									    items:[{ 
									        xtype:"textarea", 
									        fieldLabel: '审核意见', 
									        name: 'contract.contractVerify.cvVerifyResult', 
									        width:600,
									        allowBlank : true,
											blankText : "请输入审核意见"
									        }] 
									}]}     
								]
						} ]
			});
	this.formPanel.loadData({
		url : __ctxPath	+ "/contract/getContract.do?contractId="+ this.contractId,
		preName : "contract",
		root : "data",
		success : function(form, action) {  
			var g = Ext.util.JSON.decode(form.responseText).data; 
			/*if(g){
				var pplStartDate = g.pplStartDate;
				var pplEndDate = g.pplEndDate;						
				if(pplStartDate!=null&&pplStartDate!=''){
					Ext.getCmp("productionPlan.pplStartDate").setValue(new Date(Date.parse(g.pplStartDate.replace(/-/g,"/"))));
				}
				if(pplEndDate!=null&&pplEndDate!=''){

					Ext.getCmp("productionPlan.pplEndDate").setValue(new Date(Date.parse(g.pplEndDate.replace(/-/g,"/"))) );
				}
			}*/

        } 
	
	});
	this.buttons = [{
		text : "取消",
		iconCls : "btn-cancel",
		scope : this,
		handler : function() {
			this.close();
		}
	} ];
},
initgridPlanPanel:function() {
	var l = new Ext.data.Store({
		proxy : new Ext.data.HttpProxy({
			url : __ctxPath + "/production/listProductionPlan.do?Q_contract.contractId_L_EQ="+this.contractId
		}),
		reader : new Ext.data.JsonReader({
			root : "result",
			totalProperty : "totalCounts",
			fields : [ {
				name : "pplId",
				type : "int"
			}, {
				name : "pplName",
				type : "string"
			}, {
				name : "pplStartDate",
				type : "string"
			}, {
				name : "pplEndDate",
				type : "string"
			}, {
				name : "createrName",
				type : "string"
			}, {
				name : "creatDate",
				type : "string"
			}, {
				name : "pplState",
				type : "string"
			},"pplNo","productionElement", "productionTechnique", "ptmsCode" ]
		}),
		remoteSort : true
	});
	l.setDefaultSort("creatDate", "desc"); 
	l.load({
		params : {
			start : 0,
			limit : 25
		}
	});
	var m = new Ext.grid.ColumnModel(			{
		columns : [
					{
						header : "pplId",
						dataIndex : "pplId",
						hidden : true
					},
					{
						header : "计划名称",
						sortable : true,
						dataIndex : "pplName",
						width : 70
					},{
						header : "计划编码",
						sortable : true,
						dataIndex : "pplNo",
						width : 60
					},
					{
						header : "生产工艺",
						sortable : true,
						dataIndex : "productionTechnique",
						width : 60,
						renderer : function(o) {
							return o != null ? o.ptName : "";
						}
					},
					{
						header : "计划开始时间",
						dataIndex : "pplStartDate",
						width : 80
					},
					{
						header : "计划结束时间",
						dataIndex : "pplEndDate",
						width : 80
					},
					/*{
						header : "创建人",
						dataIndex : "createrName",
						width : 70
					},
					{
						header : "创建时间",
						dataIndex : "creatDate",
						width : 80
					},*/
					{
						header : "计划状态",
						sortable : true,
						dataIndex : "ptmsCode",
						width : 50,
						renderer : function(q) {
							if (q) {
								return q.codeName
							}
						}
					} ],
			defaults : {
				sortable : true,
				menuDisabled : true,
				width : 100
			},
			listeners : {
				hiddenchange : function(o, p, q) {
					saveConfig(p, q);
				}
			}
		});
	this.gridPlanPanel = new Ext.grid.GridPanel({
		region : "center",
		id : "ProductionPlanViewGrid",
		height:150,
		store : l,
		shim : true,
		trackMouseOver : true,
		disableSelection : false,
		loadMask : true,
		cm : m,
		viewConfig : {
			forceFit : true,
			enableRowBody : false,
			showPreview : false
		},
		bbar : new HT.PagingBar({
			store : l
		})
	});
}
});
ContractCloseShow.eqshow = function(a, c) {
	new ProcessQualityDetail({
		ppeId : a
	}).show();
};


